using UnityEngine;
using UnityEngine.UI;

namespace GameCore
{
    public class UI_Wait : UIBase<UI_Wait>, IInfoForm
    {
        public Text waitTip;
        public Image progross;
        private string message;
        private float waitTime;

        private void OnEnable()
        {
            waitTime = Time.time;
        }

        private void Update()
        {
            waitTip.text = message + $" ({(int)(Time.time - waitTime)})";
        }

        public void ShowUI(string info)
        {
            ShowUI();
            waitTip.text = message = info;
            progross.fillAmount = 1f;
        }

        public void ShowUI(string info, float value)
        {
            ShowUI();
            waitTip.text = message = info;
            progross.fillAmount = value;
        }
    }
}